﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DigitalImage.softLib.stages._6DictionaryCheck {
    class CLevenstein:IDictonaryCheck {
        private CDictionary dictionary;

        public CLevenstein(string filePath, string wordPattern) {
            dictionary=new CDictionary(filePath, wordPattern);
        }

        public void addLowPricePair(char c1, char c2) {
            dictionary.addSmallPricePair(c1, c2);
        }

        public void setChangedCharacted(char oldCharacter, char newCharacter) {
            List<string> wordDictionary=dictionary.wordDictionary;
            for(int i=0;i<wordDictionary.Count;i++) {
                wordDictionary[i]=wordDictionary[i].Replace(oldCharacter, newCharacter);
            }
        }

        public string transform(List<string> words) {
            string[] w;
            string result="";
            foreach(string row in words){
                w=row.Split(' ');
                for(int i=0;i<w.Length;i++){
                    result+=dictionary.findNearesWord(w[i].Trim())+" ";
                }
                result=result.Trim()+"\n";
            }
            return result.Trim();
        }
    }
}
